﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Interfaces;
using DAOBase;
using Entities;

namespace Business
{
    public class FileBusinessLogic
    {
        IHostedFileDAO hf_dao;
        IStorageDAO st_dao;
        public static string UploadDir { get; set; }
        public static string StorageDir { get; set; }

        public FileBusinessLogic()
        {
            var facade = new DAOFacade();
            hf_dao = facade.GetFactory().GetHostedFileDAO();
            st_dao = facade.GetFactory().GetStorageDAO();
        }

        public HostedFile LoadHostedFile(int id)
        {
            return hf_dao.LoadHostedFile(id);
        }

        public int GetFileID(string short_link)
        {
            return hf_dao.GetFileID(short_link);
        }

        public bool HostedFileExists(int id)
        {
            return hf_dao.HostedFileExists(id);
        }

        public void StoreFile(string just_uploaded_path, HostedFile src)
        {
            st_dao.StoreFile(just_uploaded_path, src);
        }

        public void DeleteFile(HostedFile src)
        {
            st_dao.DeleteFile(src);
        }

        public long GetUsedSpaceValue(User user)
        {
            return st_dao.GetUsedSpaceValue(user);
        }
    }
}
